Exchange - WebSockets instead of polling (for User and Chat updates) - #1775
Merged
Conversation
- Updated pubspec.yaml to include web_socket_channel dependency. - Enhanced ExchangeLocator to register ExchangeNotificationDatasource, ExchangeNotificationRepository, and ExchangeNotificationUsecase. - Integrated ExchangeNotificationUsecase into ExchangeCubit and ExchangeSupportChatCubit for handling notifications. - Implemented WebSocket connection management in ExchangeCubit and ExchangeSupportChatCubit. - Updated ExchangeSupportChatScreen to utilize the new ExchangeNotificationUsecase.
- Added new datasources for image picking, file sharing, and permissions in ExchangeLocator. - Integrated PickImageAttachmentsUsecase and ShareAttachmentUsecase into ExchangeSupportChatCubit for improved attachment handling. - Refactored addAttachment method to utilize the new use cases for better error management and code clarity. - Updated ExchangeSupportChatScreen to include the new use cases in the cubit initialization.
- Updated ExchangeNotificationDatasource to improve WebSocket connection handling, including a new method for building WebSocket URLs. - Added connection state management to prevent multiple simultaneous connection attempts. - Enhanced error handling during connection failures and implemented auto-reconnect logic. - Modified ExchangeCubit to filter messages for user notifications based on multiple types. - Integrated ExchangeListener in main.dart to manage WebSocket connections more effectively.
kumulynja
requested changes
Jan 14, 2026
Collaborator
|
Once all these comments are made into separate issues and this PR is tested and working we can merge. |
- Removed ExchangeNotificationRepository and ExchangeNotificationUsecase to streamline notification handling. - Introduced ExchangeNotificationService for improved WebSocket management and message handling. - Updated ExchangeLocator and related classes to utilize the new service, ensuring proper registration and dependency injection. - Adjusted ExchangeCubit and ExchangeSupportChatCubit to connect and manage notifications through the new service.
Contributor
Author
|
@kumulynja please re-review this pr. |
kumulynja
self-requested a review
January 19, 2026 12:25
kumulynja
approved these changes
Jan 19, 2026
8 tasks
i5hi
approved these changes
Jan 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔔 1. Real-Time Notifications via WebSocket
Before: User data (balance, KYC status, groups) was polled every 5 seconds using a timer, causing unnecessary network requests and delayed updates.
After: Implemented WebSocket-based real-time notifications that push updates instantly when changes occur:
💬 2. Enhanced Support Chat Experience
Real-time message delivery:
Improved attachment handling:
🔄 3. Smarter Connection Lifecycle Management
Login/Logout awareness:
Network environment switching (Mainnet ↔ Testnet):
Auto-reconnect on disconnection:
🏗️ 4. Architecture Improvements (Supporting Better UX)
ExchangeListenerExchangeCubitconnectWebSocket,disconnectWebSocket,reconnectWebSocket)ExchangeSupportChatCubit📁 New Files Added
exchange_listener.dartexchange_notification_datasource.dartexchange_notification_usecase.dartpick_image_attachments_usecase.dartshare_attachment_usecase.dartpermission_datasource.dartimage_picker_datasource.dartfile_share_datasource.dart✨ Key User-Facing Benefits